<template>
  <div class="peopleManage-content">
          <div class="peopleManageBox">
                <div class="headerBox">
                      <div class="line"></div>
                      <div class="title">人员管理查询</div>
                </div>

                <div class="header-search">
                        <div class="searchBox">
                          <div class="lable">名称</div>
                           <el-input
                            v-model="queryParams.personnelName"
                            placeholder="请输入管理相对人名称"
                            clearable
                            @keyup.enter.native="handleQuery"
                          />
                        </div> 
                         <div class="searchBox">
                          <div class="lable">身份证号码</div>
                           <el-input
                            v-model="queryParams.identityNumber"
                            placeholder="请输入身份证号码"
                            clearable
                            @keyup.enter.native="handleQuery"
                          />
                        </div> 
                        <div class="searchBox">
                             <el-button class="search-btn" type="primary" icon="" size="" @click="handleQuery">搜索</el-button>
                             <el-button class="search-btn" icon="" size="" @click="resetQuery">重置</el-button>
                        </div>
                </div>

                <el-table :data="infoList" border>
                  <el-table-column label="序号" align="center" type="index" />
                  <el-table-column label="人员名称" align="center" prop="personnelName" />
                  <el-table-column label="身份证号" align="center" prop="identityNumber" /> 
                  <el-table-column label="联系电话" align="center" prop="phonenumber" />   
                  <el-table-column label="工作单位" align="center" prop="enterpriseName" /> 
                  <el-table-column label="所属岗位/工种" align="center" prop="postName" /> 
                  <el-table-column label="操作" align="left" prop="case" width="600">
                        <template slot-scope="scope">
                                <el-button
                                size="mini"
                                type="text"
                                @click="handleTest(scope.row,1)"
                                >查看职业健康检查数据</el-button>
                                <el-button
                                size="mini"
                                type="text"
                                @click="handleTest(scope.row,2)"
                                >企业体检结果告知书</el-button>
                                <el-button
                                size="mini"
                                type="text"
                                @click="handleTest(scope.row,3)"
                                >查看调岗材料</el-button>
                                <el-button
                                size="mini"
                                type="text"
                                @click="handleTest(scope.row,4)"
                                >查看疑似职业病报告</el-button>
                                <el-button
                                size="mini"
                                type="text"
                                @click="handleTest(scope.row,5)"
                                >查看诊断委托材料</el-button>
                                <el-button
                                v-if="scope.row.appointmentImgUrl"
                                size="mini"
                                type="text"
                                @click="handleTest(scope.row,6)"
                                >查看任命书</el-button>
                        </template>
                    </el-table-column > 
                </el-table>
                <pagination
                    v-show="total>0"
                    :total="total"
                    :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getPersonnelListFn"
                  />
                <div class="bottomBtnCss">
                  <el-button @click="goBackBtn">返回</el-button>
                 </div>
          </div>
  </div>
</template>

<script>
  import { getPersonnelList} from "@/api/zhangping/occupational";
  export default {
    data() {
      return {
         currentPage:1,
         infoList:[{time:'2024-12-12',case:'还可以'},{time:'2024-12-12',case:'还可以'},
         {time:'2024-12-12',case:'还可以'},{time:'2024-12-12',case:'还可以'},
         {time:'2024-12-12',case:'还可以'},{time:'2024-12-12',case:'还可以'}],
          queryParams: {  
              personnelName:'', // 管理相对人名称
              creditCode:'',  // 统一社会信用代码
              identityNumber:'',   // 身份证号码
              pageNum: 1,
              pageSize: 10,
            },
            total:0
      };
    },
    created() {
        this.queryParams.creditCode = this.$route.query.creditCode
        this.getPersonnelListFn()
    },
    methods: {
     getPersonnelListFn(){
         getPersonnelList(this.queryParams).then(res=>{
                if(res.code == 200){
                     this.infoList = res.rows
                     this.total = res.total
                }else{
                     this.$message.error(res.msg);  
                }    
         })
     },
      handleQuery(){
               this.getPersonnelListFn()
      },
      resetQuery(){
             this.queryParams.personnelName = ''  
             this.queryParams.creditCode = ''  
             this.queryParams.identityNumber = ''  
             this.queryParams.pageNum = 1  
             this.queryParams.pageSize = 10  
       },
       handleTest(item,index){
           let creditCode = this.queryParams.creditCode
           let personnelId = item.id    
           switch(index){
                case 1: 
                      this.$router.push(`/careerHygiene/test2/healthExamination?creditCode=${creditCode}&personnelId=${personnelId}`)
                break;
                case 2: 
                      this.$router.push(`/careerHygiene/test2/physicalExamination?creditCode=${creditCode}&personnelId=${personnelId}`)
                break;
                case 3: 
                      this.$router.push(`/careerHygiene/test2/transferMaterial?creditCode=${creditCode}&personnelId=${personnelId}&type=${index}`)
                break;
                 case 4: 
                      this.$router.push(`/careerHygiene/test2/transferMaterial?creditCode=${creditCode}&personnelId=${personnelId}&type=${index}`)
                break;
                 case 5: 
                      this.$router.push(`/careerHygiene/test2/transferMaterial?creditCode=${creditCode}&personnelId=${personnelId}&type=${index}`)
                break;
                 case 6: 
                      this.$router.push(`/careerHygiene/test2/appointBook?id=${item.id}`)
                break;
                default: 
                break; 
           }   
        },
      goBackBtn(){
          this.$router.back()
      },
    }
  };
</script>
<style lang="scss" scoped>
         .display-fx-center{
             display: flex;
             align-items: center;
         }
         .peopleManage-content{
              overflow-y: auto;
              position: relative;
              background-color: #fff;
              padding: 40px 20px;
              border-radius: 10px;
              height: calc( 100vh - 66px - 40px);
             .peopleManageBox{
                    padding-bottom:40px;

              }
           .headerBox{
                font-size: 16px;
                color: #484848;
                font-weight: bold;
                // margin-top:40px;/
                margin-bottom:15px;
                @extend .display-fx-center;
                .line{
                  width: 4px;
                  height: 12px;
                  background: #5D85FF;
                  border-radius: 6px 6px 6px 6px;
                  margin-right:6px;
                }
             }
             .header-search{
                   flex-wrap: wrap;
                   @extend .display-fx-center; 
                  .searchBox{
                    font-size: 14px;
                    color: #797C84;
                     margin-right:40px;
                      margin-bottom:15px; 
                      @extend .display-fx-center; 
                      .lable{
                           flex-shrink: 0;
                           margin-right:10px; 
                      } 
                      .search-btn{
                        padding: 8px 20px!important;
                      }
                  }
             }
          }
          .bottomBtnCss{
            text-align: right;
            position: fixed;
            bottom: 40px;
            right: 40px; 
        }
        ::v-deep{  
           .el-table__header-wrapper th{
                 background: #F4F8FF!important;       
           }
            .el-image,.el-image__inner{
               width: 80px!important;
               height: 30px!important;
            }
          .header-search{
            .el-input .el-input__inner{
              height: 32px!important;
              line-height: 32px!important;
              width: 240px;
            }
            .el-date-editor{
                height: 32px!important;
                line-height: 32px!important;
            }
            .el-range-separator,.el-input__icon{
                line-height: 24px!important;   
            }
        }
        }
        
</style>
